/*
	Simple Software Renderer (SSRenderer)
	Copyright (C) 2007 Piotr Orzechowski <piotr.orzechowski@gmail.com>

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef SDLDEVICE_H
#define SDLDEVICE_H

#include "./ssrenderer/SSR.h"

#if defined(WIN32)
	#include "./win32/SDL-1.2.11/include/SDL.h"
	#include "./win32/SDL-1.2.11/include/SDL_Main.h"
#endif

#if defined(MSVC)
    #pragma comment(lib, "SDL.lib")
    #pragma comment(lib, "SDLmain.lib")
#endif

namespace deviceSDL
{

using ssr::ISSRDevice;
using ssr::SSRRenderTarget;
using ssr::createDevice;
using ssr::u32;
using ssr::s32;

/**
	SSRDevice is an implementation of SSR display device using SDL library.
	For description of particular members look at ISSRDevice header file.
*/
class SSRDevice :
	public ISSRDevice
{
	// This one must be included in device implementation class
	friend int createDevice<SSRDevice>(ISSRDevice* &pDevice, u32 width, u32 height, const char* pTitle);

public:

	void ToggleFullscreen(bool flag);

	void FlushBuffers();

	SSRRenderTarget* GetRenderTarget() const;

	const char* GetInfo() const;

protected:

    s32 _CreateDevice(u32 width, u32 height, const char* pTitle);

	/**
		Protected default constructor (used by createDevice() only).
	*/
	SSRDevice();

	/**
		Destructor.
	*/
	virtual ~SSRDevice();

	/** Screen SDL surface */
	SDL_Surface *m_pScreenSurface;

	/** Working SDL surface */
	SDL_Surface *m_pWorkingSurface;

	/** Primary rendering target. */
	SSRRenderTarget* m_pRenderTarget;
};

} // namespace

#endif
